package com.ruoyi.develop.process.processPleaseBuy.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.process.processPleaseBuy.domain.ProcessPleaseBuy;
import com.ruoyi.develop.process.processPleaseBuy.service.IProcessPleaseBuyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 请购单操作记录Controller
 * @author lmm
 * @date 2025-06-10
 */
@RestController
@RequestMapping("/processPleaseBuy/processPleaseBuy")
public class ProcessPleaseBuyController extends BaseController {
    @Autowired
    private IProcessPleaseBuyService processPleaseBuyService;

    /**
     * 查询请购单操作记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ProcessPleaseBuy entity) {
        startPage();
        List<ProcessPleaseBuy> list = processPleaseBuyService.selectList(entity);
        return getDataTable(list);
    }

    /**
     * 导出请购单操作记录列表
     */
    @Log(title = "请购单操作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProcessPleaseBuy entity) {
        List<ProcessPleaseBuy> list = processPleaseBuyService.selectList(entity);
        ExcelUtil<ProcessPleaseBuy> util = new ExcelUtil<ProcessPleaseBuy>(ProcessPleaseBuy. class);
        util.exportExcel(response, list, "请购单操作记录数据");
    }

    /**
     * 获取请购单操作记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(processPleaseBuyService.selectById(id));
    }

    /**
     * 新增请购单操作记录
     */
    @Log(title = "请购单操作记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ProcessPleaseBuy entity) {
        return toAjax(processPleaseBuyService.insert(entity));
    }

    /**
     * 修改请购单操作记录
     */
    @Log(title = "请购单操作记录", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody ProcessPleaseBuy entity) {
        return toAjax(processPleaseBuyService.update(entity));
    }

    /**
     * 删除请购单操作记录
     */
    @Log(title = "请购单操作记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(processPleaseBuyService.deleteByIds(ids));
    }
}
